home *** CD-ROM | disk | FTP | other *** search
- Documentation for the BlueBag Unit - Version 5.2
-
- This unit of handy procedures was compiled for Turbo Pascal version 5.0
- Routines are available for modifying the cursor, CRT tricks, dates, string
- processing, testing printer status, and multiple overlapping windows. This
- updated unit was largely rewritten in Assembler for reduced size and faster
- performance. Desirable in itself this unit is essential for the AtSayGet
- line editing procedures available in the ATSAY52.ARC file. The interface and
- dependencies are noted below followed by an explanation of each routine.
-
- UNIT BlueBag;
-
- INTERFACE
- USES
- Crt,DOS;
-
- TYPE
- Date = LONGINT;
- DateString = STRING[8]; {'MoDyYear' expected. eg: '07041776' = Independence}
- DofW = 1..7;
- LptRange=0..2;
- MofY = 1..12;
- Xrange=1..80;
- Yrange=1..25;
- CONST
- BadDate = $7FFFFFFF;
- DayName : ARRAY[DofW] OF STRING[9] =
- ('Saturday','Sunday','Monday','Tuesday','Wednesday','Thursday','Friday');
- MonthName : ARRAY[MofY] OF STRING[9] =
- ('January','February','March','April','May','June','July','August',
- 'September','October','November','December');
- VAR
- IsColor : BOOLEAN; {Display mode at startup}
- StartScan,
- StopScan : BYTE; {Cursor shape at startup}
-
- {cursor procedures}
- PROCEDURE CursorSave; {obj code}
- PROCEDURE CursorOn; {obj code}
- PROCEDURE CursorOff; {obj code}
- PROCEDURE RestoreCursor; {obj code}
- PROCEDURE SetCursor(ScanStart,ScanStop:BYTE); {obj code}
- {CRT procedures}
- PROCEDURE CLEAR(X1,Y1,X2,Y2:INTEGER);
- PROCEDURE DrawBox(X1,Y1,X2,Y2,LineStyle:BYTE);
- PROCEDURE RestoreVideo;
- PROCEDURE ReverseVideo;
- PROCEDURE WAIT;
- {date functions}
- FUNCTION DateStringToDate(DS:DateString):Date;
- FUNCTION DateToDateString(DT:Date):DateString;
- FUNCTION DaysBetween(Early,Late:Date);LongInt;
- FUNCTION DayOfWeek(DT:Date):DofW;
- FUNCTION IncDate(DT:Date; Delta:Longint):Date;
- FUNCTION MonthOfYear(DT:Date):MofY;
- FUNCTION SysDate:Date;
- FUNCTION ValidDate(DS:DateString):BOOLEAN;
- {string procedures}
- FUNCTION IsBlank(TextStr:STRING):BOOLEAN;
- PROCEDURE NoBlanks(VAR HasBlanks:STRING);
- FUNCTION Trim(LongLine:STRING):STRING;
- FUNCTION UpperCase(S:STRING):STRING; {obj code}
- {device procedures}
- FUNCTION OnFile(FileName:STRING):BOOLEAN;
- FUNCTION PrinterOnLine(LPTnum:LptRange):BOOLEAN; {obj code}
- {window procedures}
- PROCEDURE OpenWindow(TX:Xrange; TY:Yrange; {Top left corner coordinates }
- BX:Xrange; BY:Yrange; {Bottom right corner coordinates }
- FRG,BKG, {Color of text and background }
- Border : BYTE; {Border style }
- Heading: STRING); {Window heading at top of frame }
- PROCEDURE CloseWindow;
-
- (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
-
- Alphabetical listing of BLUEBAG procedures and functions and an explanation
- of the purpose of each:
-
-
- CLEAR clears screen area defined by the coordinates using current text
- attribute. It is relative to any window that may be open.
- eg: Clear(5,5,10,10); {clears screen fron 5,5, to 10,10}
-
- CLOSEWINDOW restores the image under the current window and frees the heap
- space that was used to store it.
- eg: CloseWindow; {closes the last window that was opened}
-
- CURSOROFF turns off the cursor after saving the current cursor shape in
- StartScan and StopScan. A call to RESTORECURSOR will reset it to its shape
- before being turned off.
- eg: CursorOff; {hides the cursoe}
-
- CURSORON sets the cursor to the default setting for the monitor in use at
- startup.
- eg: CursorOn; {turns on the cursor}
-
- CURSORSAVE saves the current cursor start and stop scan lines into the global
- variables StartScan and StopScan.
- eg: CursorSave; {saves the cursor shape}
-
- DATESTRINGTODATE returns a (LongInt) Date from a (STRING[8]) DateString.
- eg: DateToDateString('07041776') returns 648869.
-
- DATETODATESTRING returns a (STRING[8]) DateString from a (LongInt) Date.
- eg: DateToDateString(648869) returns '07041776'.
-
- DAYSBETWEEN returns the number of days between the early and late dates.
- eg: DaysBetween(DateStringToDate('07041776'),DateToDateString('07041989'))
- returns 77,796 (days).
-
- DAYOFWEEK returns the ordinal day of week from a LongInt Date; 1=Friday, etc.
- eg: CanadaDay:DateString='07011867';
- DayOfWeek(DateStringToDate(CanadaDay)) returns 4 and
- DayName[DayOfWeek(DateStringToDate(CanadaDay))] returns 'Tuesday'.
-
- DRAWBOW draws a box defined by the coordinates. LineStyles are 1 (single),
- 2 (double), or 32..254 (ASCII #32..#254).
- eg: DrawBox(5,5,10,10,219); {draws a box from 5,5, to 10,10 in CHR(219) = █ }
-
- INCDATE incriments a (LongInt) Date by delta days.
-
- ISBLANK returns True if the string has is nul or all spaces, or False if the
- string has at least one character.
- eg: IsBlank('Something is here') is False; IsBlank(' ') is True;
-
- MONTHOFYEAR returns the ordinal month of a (LongInt) Date.
- eg: MonthName[MonthOfYear(648869)] gives 'July'.
-
- NOBLANKS removes all blanks from a string.
- eg: SomeStr:STRING='JUNK 1 ';
- SomeStr:=SomeStr+'.BAK'; (* Now SomeStr = 'JUNK 1 .BAK' *)
- NoBlanks(SomeStr); (* Now SomeStr = 'JUNK1.BAK' *)
-
- ONFILE returns True if specified file exists. FileName defaults to the current
- directory or looks to the path specified.
- eg: OnFile('\UTIL\PCTOOLS.EXE') OR OnFile('PCTOOLS.EXE') results in True if
- PCTOOLS.EXE is in the \util or current directory, otherwise returns False.
-
- OPENWINDOW first stores the screen display within the coordinates specified
- and saves the image on the heap. It then draws a border using a border style
- and TextAttrs specified in the parameters. An optional title is permitted at
- the top of the window. A window is then opened within the border and the
- screen cleared. Up to 9 windows may be opened and they can overlap.
- eg: OpenWindow(5,5,50,12,White,Red,1,' HI MOM ') draws a single line frame
- in white on a red background from 5,5 to 50,12 and opens a window within
- the borders. The words ' HI MOM ' are centered at the top of the border.
-
- PRINTERONLINE returns True if printer port status reports ready, else False.
- LPTnum RANGE IS 0..2 corresponding to the printer ports 1..3
- eg: PrinterOnLine(0) is False if you don't have a printer on port 1 or if you
- do but the printer is off line. Tests out fine on Epson but other printers
- may not respond as expected.
-
- RESTORECURSOR restores the cursor to the shape it had before being turned off
- by the CursorOff procedure or modified by the SetCursor procedure.
- eg: RestoreCursor;
-
- RESTOREVIDEO restores the video attribute to the condition before calling the
- ReverseVideo procedure (See below).
-
- REVERSEVIDEO displays black charactors on light background on a mono screen;
- On color screens it displays a suitable dark colored charactor on light b/g.
-
- SETCURSOR sets cursor start and stop scans for altering cursor shape.
- SetCursor(StartScan,StopScan) will always display a block cursor regardless of
- the monitor used.
- eg: SetCursor(5,6); { If used on a mono screen the cursor will be a dash "-" }
-
- SYSDATE returns a (Longint) Date from the system clock; The result varies
- depending on the system date.
-
- TRIM returns a string with any leading or trailing spaces removed.
- eg: Tight:=Trim(' and then she said '); { Tight = 'and then she said' }
-
- UPPERCASE returns a string in uppercase. Corrected version of assembly code
- listed on pgs 213-4 of the TP5 manual.
- eg: Uppidy:=UpperCase('and then she said'); { Uppidy='AND THEN SHE SAID' }
-
- VALIDDATE returns True if the DateString is valid, else False.
- eg: ValidDate('02291988') returns True but
- ValidDate('02291989') returns False (because 1989 is not a leapyear).
-
- WAIT turns off cursor, prints the message 'Press any key to continue' at the
- current cursor location, waits for any key to be pressed, and then restores
- the cursor.
- eg: Wait; { Displays: Press any key to continue }
-
- (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
-
- {See Demo.pas for some examples of how to use the routines in this unit}